
<template>
  <div class="input-item">
    <el-form :model="deviceform" label-width="250px">
        <div class="parameType-wrap">
            <div class="parameType">
              <div class="button">
                <!-- <span>基本参数配置</span> -->
                <el-button style="float: right; padding:4px 8px;" type="primary" @click="operationClick">确定</el-button>
              </div>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理心跳间隔：">
                  <el-input v-model="deviceform.agent_hand_shake_interval"><span slot="append">秒</span></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理心跳超时次数：">
                  <el-input v-model="deviceform.lost_hand_shake_times"></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理网络连接检测间隔：">
                  <el-input v-model="deviceform.check_agent_net_status_interval"><span slot="append">秒</span></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理定时更新参数间隔：">
                  <el-input v-model="deviceform.refresh_agent_param_interval"><span slot="append">秒</span></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理离线日志上送间隔：">
                  <el-input v-model="deviceform.agent_report_offline_interval"><span slot="append">秒</span></el-input>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理离线日志保存尺寸：">
                  <el-input class="input-style" v-model="deviceform.agent_offline_max_file_size"><span slot="append">M</span></el-input>
                  <span>（0表示不保存）</span>
                </el-form-item>
              </el-col>

              <el-col :xs="24" :sm="24" :lg="24">
                <el-form-item label="终端代理自动升级检测间隔：">
                  <el-input class="input-style" v-model="deviceform.agent_auto_upgrade_interval"><span slot="append">秒</span></el-input>
                  <span>（0表示不升级）</span>
                </el-form-item>
              </el-col>
            </div>
        </div>
    </el-form>
  </div>
</template>

<script>
import { connrequest } from '@/api/firstPage'
export default {
    data() {
        return {
            deviceform:{
              agent_hand_shake_interval:0,
              lost_hand_shake_times:'',
              agent_offline_max_file_size:0,
              check_agent_net_status_interval:0,
              refresh_agent_param_interval:0,
              check_net_status_interval:0,
              agent_auto_upgrade_interval:0
            },
            oldData:[]
        }
    },
    created(){
      this.getData()
      // console.log();

    },
    methods:{
      //
      async getData(){
        // const data = {}
        const res = await connrequest('GetParamThreshhold')
        // console.log(res.Data);
        this.oldData = res.Data;
        res.Data = res.Data.map(item => {
          for (const i in this.deviceform) {
            if (item.Name === i) {
              this.deviceform[i] = item.Value
            }
          }

        })
      },
      async operationClick(){

        this.oldData = this.oldData.map(item => {
          for (const key in this.deviceform) {
            if(item.Name === key){
              item.Value = this.deviceform[key]
            }
          }
          return item
        })
        console.log(this.oldData);
        const data = {
          Data:this.oldData
        }
        const res = await connrequest('SetParamThreshhold',data)
        this.$message.success('修改成功')
        this.getData();
      }
    }
}
</script>

<style lang="scss" scoped>
/* @import url(); 引入css类 */
  .parameType-wrap{
    display:flex;
    flex-wrap: wrap;
  }
  ::v-deep.input-item{
    // margin-top: 10px;
    .parameType{
      border: 1px solid #eceff5;
      border-radius: 3px;
      width: 800px;
    //   padding: 10px;
      margin: 0px;
      box-shadow: 0 0 10px #eceff5;
      .button{

        border-bottom: 1px solid #eceff5;
        padding-bottom : 32px;
      }
    }
    .el-form-item{
      margin-bottom: 6px;
    }
    .el-input-group__append, .el-input-group__prepend{
      width: 60px;
      padding: 0;
      text-align: center;
    }
  }
  .button{
    margin-bottom: 20px;
  }
  ::v-deep.el-form-item{
    label{
      font-weight: 500;
    }
  }
  .input-style{
    width: 70% !important;
}

</style>
